package com.test.reggieadmin.http;

import com.tencent.mmkv.MMKV;
import com.test.reggieadmin.bean.BaseBean;
import com.test.reggieadmin.bean.CategoryDetailsBean;
import com.test.reggieadmin.bean.CategoryListBean;
import com.test.reggieadmin.bean.DishDetailsBean;
import com.test.reggieadmin.bean.DishListBean;
import com.test.reggieadmin.bean.DishPageBean;
import com.test.reggieadmin.bean.EmployeeBean;
import com.test.reggieadmin.bean.EmployeeDetailsBean;
import com.test.reggieadmin.bean.PageBean;
import com.test.reggieadmin.bean.PageCategoryBean;
import com.test.reggieadmin.bean.SetmealDetailsBean;
import com.test.reggieadmin.bean.SetmealPageBean;

import java.util.Map;

import io.reactivex.Observable;
import okhttp3.MultipartBody;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Part;
import retrofit2.http.Path;
import retrofit2.http.Query;

/**
 * 接口的管理类
 */
public class API {

    public static MMKV kv = MMKV.defaultMMKV();

    public interface Api {
        //登录
        @POST("employee/login")
        Observable<EmployeeBean> login(@Body Map<String, Object> map);

        //退出登录
        @POST("employee/logout")
        Observable<BaseBean> logout();

        //添加员工
        @POST("employee")
        Observable<BaseBean> save(@Body Map<String, Object> map);

        //分页查询员工列表
        @GET("employee/page")
        Observable<PageBean> page(@Query("skip") int skip, @Query("pageSize") int pageSize,
                                  @Query("name") String name);

        //根据id查询员工信息
        @GET("employee/{id}")
        Observable<EmployeeDetailsBean> employeeDetails(@Path("id") String id);

        //修改员工信息
        @PUT("employee")
        Observable<BaseBean> update(@Body Map<String, Object> map);

        //添加分类
        @POST("category")
        Observable<BaseBean> addCategory(@Body Map<String, Object> map);

        //分页查询分类
        @GET("category/page")
        Observable<PageCategoryBean> pageCategory(@Query("skip") long skip, @Query("pageSize") int pageSize);

        //删除分类
        @DELETE("category")
        Observable<BaseBean> deleteCategory(@Query("id") String id);

        //根据id查询分类
        @GET("category/{id}")
        Observable<CategoryDetailsBean> categoryDetails(@Path("id") String id);

        //修改分类
        @PUT("category")
        Observable<BaseBean> updateCategory(@Body Map<String, Object> map);

        //根据条件查询分类数据
        @GET("category/list")
        Observable<CategoryListBean> categoryList(@Query("type") int type);

        //新增菜品
        @POST("dish")
        Observable<BaseBean> addDish(@Body Map<String, Object> map);

        //文件上传
        @Multipart
        @POST("common/upload")
        Observable<BaseBean> upload(@Part MultipartBody.Part part);

        //菜品信息分页查询
        @GET("dish/page")
        Observable<DishPageBean> dishPage(@Query("page") int page, @Query("pageSize") int pageSize,
                                          @Query("name") String name);

        //根据id查询菜品信息和对应的口味信息
        @GET("dish/{id}")
        Observable<DishDetailsBean> dishDetails(@Path("id") String id);

        //修改菜品
        @PUT("dish")
        Observable<BaseBean> updateDish(@Body Map<String, Object> map);

        //根据条件查询对应的菜品数据
        @GET("dish/list")
        Observable<DishListBean> dishList(@Query("categoryId") String categoryId);

        @DELETE("dish")
        Observable<BaseBean> deleteDish(@Query("ids") String ids);

        //新增套餐
        @POST("setmeal")
        Observable<BaseBean> addSetmeal(@Body Map<String, Object> map);

        //套餐信息分页查询
        @GET("setmeal/page")
        Observable<SetmealPageBean> setmealPage(@Query("page") int page, @Query("pageSize") int pageSize,
                                                @Query("name") String name);

        //删除套餐
        @DELETE("setmeal")
        Observable<BaseBean> deleteSetmeal(@Query("ids") String ids);

        //根据id查询套餐信息和对应的菜品信息
        @GET("setmeal/{id}")
        Observable<SetmealDetailsBean> setmealDetails(@Path("id") String id);

        //修改套餐
        @PUT("setmeal")
        Observable<BaseBean> updateSetmeal(@Body Map<String, Object> map);

    }
}
